using System;
using Rhino.Mocks;
using Rhino.Mocks.Interfaces;

namespace noug.tdd.tests {
    public static class MoreRhinoMocksExtensions {
        public static IMethodOptions<T> Always<T>(this IMethodOptions<T> mockOps) {
            return mockOps.Repeat.Any();
        }
        public static IMethodOptions<R> DoNotExpect<T, R>(this T mock, Function<T, R> action) where T : class {
            return mock.Expect(action).Repeat.Never();
        }
        public static IMethodOptions<RhinoMocksExtensions.VoidType> DoNotExpect<T>(this T mock, Action<T> action) where T : class {
            return mock.Expect(action).Repeat.Never();
        }
        public static IMethodOptions<R> DoNotExpectSimilar<T, R>(this T mock, Function<T, R> action) where T : class {
            return mock.Expect(action).IgnoreArguments().Repeat.Never();
        }
        public static IMethodOptions<RhinoMocksExtensions.VoidType> DoNotExpectSimilar<T>(this T mock, Action<T> action) where T : class {
            return mock.Expect(action).IgnoreArguments().Repeat.Never();
        }

        public static IMethodOptions<R> ExpectSimilar<T, R>(this T mock, Function<T, R> action) where T : class {
            return mock.Expect(action).IgnoreArguments();
        }
        public static IMethodOptions<RhinoMocksExtensions.VoidType> ExpectSimilar<T>(this T mock, Action<T> action) where T : class {
            return mock.Expect(action).IgnoreArguments();
        }
        public static IMethodOptions<R> StubSimilar<T, R>(this T mock, Function<T, R> action) where T : class {
            return mock.Stub(action).IgnoreArguments();
        }
        public static IMethodOptions<object> StubSimilar<T>(this T mock, Action<T> action) where T : class {
            return mock.Stub(action).IgnoreArguments();
        }
        public static T ResetExpectations<T>(this T mock) where T : class {
            mock.BackToRecord(BackToRecordOptions.Expectations);
            mock.Replay();
            return mock;
        }
    }
}
